package com.itheima.service.impl;

import com.itheima.domain.UserEntity;
import com.itheima.service.MongoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MongoServiceImpl implements MongoService {
    @Autowired
    private MongoTemplate mongoTemplate;

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public  List<UserEntity> find() {
        Query query = new Query(Criteria.where("name").is("lisi"));
        List<UserEntity> userEntities = mongoTemplate.find(query, UserEntity.class);
        List<UserEntity> userEntities1 = mongoTemplate.findAll( UserEntity.class);
        return userEntities1;
    }


}
